home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM Gold
/
Light ROM Gold.iso
/
arexx
/
modeler
/
bezier.lwm
< prev
next >
Wrap
Text File
|
1995-03-23
|
2KB
|
115 lines
/* Bezier curve creator
* Use selected control points to create a bezier curve.
* By Monte Ohrtá⌐ 1994 The Rendering Plant Inc. */
Version = 1.0
address "LWModelerARexx.port"
libadd = addlib("LWModelerARexx.port",0)
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
call notify(1,"!Can't find "MATHLIB)
exit
END
sysnam = 'Bezier Curves'
signal on error
signal on syntax
call sel_mode(USER)
call req_begin sysnam
id_txt = req_addcontrol("Create Bezier",'T',"Curves")
id_txt2 = req_addcontrol("By Monte Ohrt",'T',"")
id_seg = req_addcontrol("Number of Points to make",'n')
id_cur = req_addcontrol("Make a Curve?",'B')
id_cntl = req_addcontrol("Keep original control points?",'B')
call req_setval id_seg, 15
call req_setval id_cur, 1
call req_setval id_cntl, 0
if (~req_post()) then do
call req_end
exit
end
curve = ""
segs = req_getval(id_seg)
cur = req_getval(id_cur)
cntl = req_getval(id_cntl)
call req_end()
n = xfrm_begin()
if n=0 then do
call notify(1,"no points selected!")
exit
end
say n
do i = 1 to n
Point.i= xfrm_getpos(i)
say Point.i
end
call xfrm_end()
if (~cntl) then do
call CUT()
end
delta = 1.0/segs
parse value point.1 with x y z
call ADD_BEGIN()
curve = curve add_point(x y z)
call meter_begin (segs-1), "Creating Bezier Curve"
do i = 1 to (segs-1)
t=i*delta
temp2=1
do z=1 to (n-1)
temp2=temp2*(1-t)
end
temp3=1
parse value point.1 with x y z .
sum=temp2*x
sum2=temp2*y
sum3=temp2*z
do k = 1 to (n-1)
temp2=temp2*(n-k)*t
temp3=temp3*k*(1-t)
temp=temp2/temp3
j=k+1
parse value point.j with x y z .
sum=sum+temp*x
sum2=sum2+temp*y
sum3=sum3+temp*z
end
curve = curve add_point(sum sum2 sum3)
call meter_step
end
parse value point.n with x y z
curve = curve add_point(x y z)
call meter_end
if (cur) then do
call ADD_CURVE curve
end
call ADD_END
if (libadd) then call remlib("LWModelerARexx.port")
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit
PointCount: PROCEDURE
n=XFRM_BEGIN()
call END_ALL()
return n